<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>控制台 - AdminMD</title>
<link rel="stylesheet" href="../static/extend/layui/css/layui.css">
<link rel="stylesheet" href="../static/css/common.css">
</head>
<body>
	<div class="layui-layout">
		<!-- .layui-header -->
		<div class="layui-header">
			<!-- 头部LOGO -->
			<div class="layui-logo">
				<a href="../">
					<i class="layui-icon layui-icon-home"></i>
					<span>AdminMD</span>
				</a>
			</div>
			<!-- 头部左侧导航 -->
			<ul class="layui-nav layui-layout-left">
				<li class="layui-nav-item" lay-unselect="">
					<a href="javascript:;" data-event="flexible" title="侧边伸缩"> 
						<i class="layui-icon layui-icon-shrink-right" id="toggle-icon"></i>
					</a>
				</li>
				<li class="layui-nav-item layui-this layui-hide-xs layui-hide-sm layui-show-md-inline-block">
					<a href="../"> 
						控制台
					</a>
				</li>
				<li class="layui-nav-item layui-hide-xs layui-hide-sm layui-show-md-inline-block">
					<a href="javascript:;"> 
						单点登录
					</a>
				</li>
				<li class="layui-nav-item layui-hide-xs" lay-unselect="">
					<a href="http://studio.disyo.com" target="_blank"> 
						工作室
					</a>
				</li>
			</ul>
			<!-- 头部右侧导航 -->
			<ul class="layui-nav layui-layout-right">
				<li class="layui-nav-item" lay-unselect="">
					<a href="javascript:;"> 
						<i class="layui-icon layui-icon-notice"></i> 
						<span class="layui-badge-dot"></span>
					</a>
				</li>
				<li class="layui-nav-item layui-hide-xs" lay-unselect="">
					<a href="javascript:;" data-event="fullscreen"> 
						<i class="layui-icon layui-icon-screen-full"></i>
					</a>
				</li>
				<li class="layui-nav-item" lay-unselect="">
					<a href="javascript:;" data-event="refresh" title="刷新"> 
						<i class="layui-icon layui-icon-refresh-3"></i>
					</a>
				</li>
				<li class="layui-nav-item" lay-unselect="" style="right: 5px;">
					<a href="javascript:;"> 
						<cite class="avatar-small"><img src="../static/img/avatar.jpg" /></cite> 
						<span class="layui-nav-more"></span>
					</a>
					<dl class="layui-nav-child layui-anim layui-anim-upbit" style="left: inherit; right: 0px;">
						<dd>
							<a href="javascript:;">个人资料</a>
						</dd>
						<dd>
							<a href="javascript:;">修改密码</a>
						</dd>
						<hr>
						<dd style="text-align: center;">
							<a href="javascript:;">退出</a>
						</dd>
					</dl>
				</li>
			</ul>
		</div>
		<!-- .layui-side -->
		<div class="layui-side">
			<div class="layui-side-scroll">
				<!-- 左侧导航区域（可配合layui已有的垂直导航） -->
				<ul class="layui-nav layui-nav-tree" lay-shrink="all" lay-filter="menu-admin">
					<li class="layui-nav-item">
						<a href="javascript:;">
							<i class="layui-icon layui-icon-console"></i> 
							<cite>控制台</cite>
						</a>
						<dl class="layui-nav-child">
							<dd>
								<a href="../">首页</a>
							</dd>
						</dl>
					</li>
					<li class="layui-nav-item">
						<a href="javascript:;">
							<i class="layui-icon layui-icon-component"></i> 
							<cite>组件</cite>
						</a>
						<dl class="layui-nav-child">
							<dd>
								<a href="javascript:;" data-href="https://www.layui.com/doc/element/layout.html">栅格栏</a>
							</dd>
							<dd>
								<a href="javascript:;" data-href="https://www.layui.com/doc/element/button.html">按钮</a>
							</dd>
							<dd>
								<a href="javascript:;" data-href="https://www.layui.com/doc/element/form.html">表单</a>
							</dd>
							<dd>
								<a href="javascript:;" data-href="https://www.layui.com/doc/element/nav.html">导航</a>
							</dd>
							<dd>
								<a href="javascript:;" data-href="https://www.layui.com/doc/element/tab.html">选项卡</a>
							</dd>
							<dd>
								<a href="javascript:;" data-href="https://www.layui.com/doc/element/progress.html">进度条</a>
							</dd>
							<dd>
								<a href="javascript:;" data-href="https://www.layui.com/doc/element/panel.html">面板</a>
							</dd>
							<dd>
								<a href="javascript:;" data-href="https://www.layui.com/doc/element/table.html">表格</a>
							</dd>
							<dd>
								<a href="javascript:;" data-href="https://www.layui.com/doc/element/timeline.html">时间线</a>
							</dd>
							<dd>
								<a href="javascript:;" data-href="https://www.layui.com/doc/modules/layer.html">弹出层</a>
							</dd>
							<dd>
								<a href="javascript:;" data-href="https://www.layui.com/doc/modules/laypage.html">分页</a>
							</dd>
							<dd>
								<a href="javascript:;" data-href="https://www.layui.com/doc/modules/upload.html">文件上传</a>
							</dd>
						</dl>
					</li>
					<li class="layui-nav-item layui-nav-itemed">
						<a href="javascript:;">
							<i class="layui-icon layui-icon-file"></i> 
							<cite>页面</cite>
						</a>
						<dl class="layui-nav-child">
							<dd class="layui-this">
								<a href="../page/editor.html">编辑器</a>
							</dd>
							<dd>
								<a href="../page/login.html">登录</a>
							</dd>
							<dd>
								<a href="../page/message.html">提示页面</a>
							</dd>
						</dl>
					</li>
					<li class="layui-nav-item">
						<a href="javascript:;">
							<i class="layui-icon layui-icon-form"></i> 
							<cite>内容</cite>
						</a>
						<dl class="layui-nav-child">
							<dd>
								<a href="javascript:;">文章</a>
							</dd>
							<dd>
								<a href="javascript:;">商品</a>
							</dd>
							<dd>
								<a href="javascript:;">相册</a>
							</dd>
							<dd>
								<a href="javascript:;">视频</a>
							</dd>
							<dd>
								<a href="javascript:;">附件</a>
							</dd>
							<dd>
								<a href="javascript:;">内容分类</a>
							</dd>
						</dl>
					</li>
					<li class="layui-nav-item">
						<a href="javascript:;">
							<i class="layui-icon layui-icon-user"></i> 
							<cite>用户</cite>
						</a>
						<dl class="layui-nav-child">
							<dd>
								<a href="javascript:;">用户管理</a>
							</dd>
							<dd>
								<a href="javascript:;">用户组</a>
							</dd>
							<dd>
								<a href="javascript:;">权限管理</a>
							</dd>
						</dl>
					</li>
					<li class="layui-nav-item">
						<a href="javascript:;">
							<i class="layui-icon layui-icon-util"></i> 
							<cite>工具</cite>
						</a>
						<dl class="layui-nav-child">
							<dd>
								<a href="javascript:;">广告</a>
							</dd>
							<dd>
								<a href="javascript:;">友情链接</a>
							</dd>
						</dl>
					</li>
					<li class="layui-nav-item">
						<a href="javascript:;">
							<i class="layui-icon layui-icon-set"></i> 
							<cite>设置</cite>
						</a>
						<dl class="layui-nav-child">
							<dd>
								<a href="javascript:;">常规设置</a>
							</dd>
							<dd>
								<a href="javascript:;">上传设置</a>
							</dd>
							<dd>
								<a href="javascript:;">邮件设置</a>
							</dd>
							<dd>
								<a href="javascript:;">短信设置</a>
							</dd>
						</dl>
					</li>
				</ul>
			</div>
		</div>
		<!-- .layui-body -->
		<div class="layui-body">
			<!-- 内容主体区域 -->
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md12">
					<div class="layui-card">
						<div class="layui-card-header">
							UEditor （dev-1.5.0）
						</div>
						<div class="layui-card-body">
							<script id="editor" name="content" type="text/plain" style="width:100%; height:400px;">
				</script>
						</div>
					</div>
				</div>
				<div class="layui-col-md12">
					<div class="layui-card">
						<div class="layui-card-body">
							<div id="btns">
							    <div class="layui-btn-container">
							        <button class="layui-btn" onclick="getAllHtml()">获得整个html的内容</button>
							        <button class="layui-btn" onclick="getContent()">获得内容</button>
							        <button class="layui-btn" onclick="setContent()">写入内容</button>
							        <button class="layui-btn" onclick="setContent(true)">追加内容</button>
							        <button class="layui-btn" onclick="getContentTxt()">获得纯文本</button>
							        <button class="layui-btn" onclick="getPlainTxt()">获得带格式的纯文本</button>
							        <button class="layui-btn" onclick="hasContent()">判断是否有内容</button>
							        <button class="layui-btn" onclick="setFocus()">使编辑器获得焦点</button>
							        <button class="layui-btn" onmousedown="isFocus(event)">编辑器是否获得焦点</button>
							        <button class="layui-btn" onmousedown="setblur(event)" >编辑器失去焦点</button>
							
							    </div>
							    <div class="layui-btn-container">
							        <button class="layui-btn" onclick="getText()">获得当前选中的文本</button>
							        <button class="layui-btn" onclick="insertHtml()">插入给定的内容</button>
							        <button class="layui-btn" id="enable" onclick="setEnabled()">可以编辑</button>
							        <button class="layui-btn" onclick="setDisabled()">不可编辑</button>
							        <button class="layui-btn" onclick=" UE.getEditor('editor').setHide()">隐藏编辑器</button>
							        <button class="layui-btn" onclick=" UE.getEditor('editor').setShow()">显示编辑器</button>
							        <button class="layui-btn" onclick=" UE.getEditor('editor').setHeight(300)">设置高度为300默认关闭了自动长高</button>
							    </div>
							
							    <div class="layui-btn-container">
							        <button class="layui-btn" onclick="getLocalData()" >获取草稿箱内容</button>
							        <button class="layui-btn" onclick="clearLocalData()" >清空草稿箱</button>
							    </div>
							
							</div>
							<div class="layui-btn-container">
							    <button class="layui-btn" onclick="createEditor()">
							    创建编辑器</button>
							    <button class="layui-btn" onclick="deleteEditor()">
							    删除编辑器</button>
							</div>
						</div>
					</div>
				</div>
			</div><!-- /.layui-row -->
		</div>
		<!-- .layui-footer -->
		<div class="layui-footer">
			<!-- 底部固定区域 -->
			2019 <a target="_blank" href="http://studio.disyo.com/item/adminmd.html">AdminMD</a>
		</div>
	</div>
	
	<!-- 辅助元素，一般用于移动设备下遮罩 -->
	<div class="layui-body-shade" data-event="shade"></div>
	
	<script src="../static/extend/layui/layui.js"></script>
	<script>
	var layuiExtend = "../static/extend/layui_extend";
	</script>
	<script src="../static/js/layout.js"></script>
	<script type="text/javascript" charset="utf-8" src="../static/extend/ueditor/ueditor.config.js"></script>
	<script type="text/javascript" charset="utf-8" src="../static/extend/ueditor/editor_api.js"> </script>
	<script type="text/javascript" charset="utf-8" src="../static/extend/ueditor/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript">
	//实例化编辑器
	//建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
	var ue = UE.getEditor('editor');
	
	function isFocus(e){
	    alert(UE.getEditor('editor').isFocus());
	    UE.dom.domUtils.preventDefault(e)
	}
	function setblur(e){
	    UE.getEditor('editor').blur();
	    UE.dom.domUtils.preventDefault(e)
	}
	function insertHtml() {
	    var value = prompt('插入html代码', '');
	    UE.getEditor('editor').execCommand('insertHtml', value)
	}
	function createEditor() {
	    enableBtn();
	    UE.getEditor('editor');
	}
	function getAllHtml() {
	    alert(UE.getEditor('editor').getAllHtml())
	}
	function getContent() {
	    var arr = [];
	    arr.push("使用editor.getContent()方法可以获得编辑器的内容");
	    arr.push("内容为：");
	    arr.push(UE.getEditor('editor').getContent());
	    alert(arr.join("\n"));
	}
	function getPlainTxt() {
	    var arr = [];
	    arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
	    arr.push("内容为：");
	    arr.push(UE.getEditor('editor').getPlainTxt());
	    alert(arr.join('\n'))
	}
	function setContent(isAppendTo) {
	    var arr = [];
	    arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
	    UE.getEditor('editor').setContent('欢迎使用ueditor', isAppendTo);
	    alert(arr.join("\n"));
	}
	function setDisabled() {
	    UE.getEditor('editor').setDisabled('fullscreen');
	    disableBtn("enable");
	}
	
	function setEnabled() {
	    UE.getEditor('editor').setEnabled();
	    enableBtn();
	}
	
	function getText() {
	    //当你点击按钮时编辑区域已经失去了焦点，如果直接用getText将不会得到内容，所以要在选回来，然后取得内容
	    var range = UE.getEditor('editor').selection.getRange();
	    range.select();
	    var txt = UE.getEditor('editor').selection.getText();
	    alert(txt)
	}
	
	function getContentTxt() {
	    var arr = [];
	    arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
	    arr.push("编辑器的纯文本内容为：");
	    arr.push(UE.getEditor('editor').getContentTxt());
	    alert(arr.join("\n"));
	}
	function hasContent() {
	    var arr = [];
	    arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
	    arr.push("判断结果为：");
	    arr.push(UE.getEditor('editor').hasContents());
	    alert(arr.join("\n"));
	}
	function setFocus() {
	    UE.getEditor('editor').focus();
	}
	function deleteEditor() {
	    disableBtn();
	    UE.getEditor('editor').destroy();
	}
	function disableBtn(str) {
	    var div = document.getElementById('btns');
	    var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
	    for (var i = 0, btn; btn = btns[i++];) {
	        if (btn.id == str) {
	            UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
	        } else {
	            btn.setAttribute("disabled", "true");
	        }
	    }
	}
	function enableBtn() {
	    var div = document.getElementById('btns');
	    var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
	    for (var i = 0, btn; btn = btns[i++];) {
	        UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
	    }
	}
	
	function getLocalData () {
	    alert(UE.getEditor('editor').execCommand( "getlocaldata" ));
	}
	
	function clearLocalData () {
	    UE.getEditor('editor').execCommand( "clearlocaldata" );
	    alert("已清空草稿箱")
	}
	</script>
</body>
</html>